package com.cater.talents.service;
import java.util.List;
import java.util.UUID;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.cater.common.BaseEntity;
import com.cater.common.PageResult;
import com.cater.query.CommonQuery;
import com.cater.sys.service.BaseService;
import com.cater.talents.dao.TbCertificateDao;
import com.cater.talents.entity.TbCertificate;


/**
* 描述：资格证书 服务实现层
* @author yong
* @date 2018/12/8
*/
@Service
public class TbCertificateServiceImpl implements BaseService<TbCertificate, CommonQuery, String> {

    @Autowired
    TbCertificateDao dao;
	
	@Override
	public PageResult<TbCertificate> findPageResult(CommonQuery query) {
		PageResult<TbCertificate> result = new PageResult<TbCertificate>();
		result.setPage(query.getPage());
		result.setPageSize(query.getRows());
		int count = dao.findCount(query);
		int first = (query.getPage() - 1) * query.getRows();
		int max = query.getRows();
		List<TbCertificate> list = dao.findList(query, first, max);
		result.setRows(list);
		result.setRecords(count);
		return result;
	}

	@Override
	public List<TbCertificate> getAll() {
		return dao.getAll();
	}

	@Override
	public List<TbCertificate> getAllCommon(CommonQuery query) {
		return dao.getAllCommon(query);
	}

	@Override
	public int save(TbCertificate t) {
		return 0;
	}

	@Override
	public String saves(TbCertificate t) {
		t.setId(UUID.randomUUID().toString().replaceAll("-", ""));
		BaseEntity.getCreate(t);
		dao.save(t);
		return t.getId();
	}

	@Override
	public void update(TbCertificate t) {
		BaseEntity.getupdate(t);
		dao.update(t);
	}

	@Override
	public void delete(String id) {
		dao.delete(id);
	}

	@Override
	public TbCertificate getById(String id) {
		return dao.getById(id);
	}
	
	public List<TbCertificate> getByTatentsId(String resumeId){
		return dao.getByTatentsId(resumeId);
	}
}